<?php
global $base_dir;
$base_dir='../';

/**** 模块调用*****/
include_once($base_dir."inc/inc_connect.php");		//通用函数包含文件
include_once("index_inc.php");
include_once("func/function.php");
include_once($base_dir."inc/manage.php");			//后台通用包含文件
?>
<?php
//接收参数
if(is_array($_GET))
{
	foreach($_GET as $key => $value)
	{
		$$key=$value;
	}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?=$lanmu_name?>-后台管理系统</title>
<link href="../style/common.css" rel="stylesheet" type="text/css" />
<script src="../js/checkform.js" type="text/javascript"></script>

<link href="../js/dq_calendar/dq_calendar.css" rel="stylesheet" type="text/css" />
<script src="../js/dq_calendar/dq_calendar.js" type="text/javascript"></script>
<script src="../js/jquery.js" type="text/javascript"></script>
<script src="../js/common2.js" type="text/javascript"></script>


<script type="text/javascript">
//删除确认
function delConfig(url,str)
{
	if(confirm(str))
	{
		location.href=url;
	}
}
</script>
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="lanmu_table">
  <tr>
    <td height="30" valign="bottom"><a href="<?=$url_list?>"><span class="lanmu_title"><?=$lanmu_name?></span></a><span class="lanmu_title2">&nbsp;&gt;&nbsp;列表</span></td>
  </tr>
</table>

<table width="100%" border="0" cellpadding="0" cellspacing="0" class="margintop30_l">
<form action="" method="get" name="search">
  <tr>
    <td height="30" class="search">
    <strong>搜索:&nbsp;</strong>订单编号
    <input name="Tord_id" type="text" value="<?=isset($_GET['Tord_id']) ? $_GET['Tord_id'] : ""?>" />
    &nbsp;&nbsp;联系人姓名:<input name="per_name" type="text" value="<?=isset($_GET['per_name']) ? $_GET['per_name'] : ""?>" />
    &nbsp;&nbsp;联系电话:<input name="per_phone" type="text" value="<?=isset($_GET['per_phone']) ? $_GET['per_phone'] : ""?>" />
    &nbsp;&nbsp;客户用户名:<input name="mem_name" type="text" value="<?=isset($_GET['mem_name']) ? $_GET['mem_name'] : ""?>" /><input type="submit" name="Submit" value="提交" /></td>
  </tr>
  </form>
</table>

<?php
$pagesize=20;
$t=new Tbl_Act($tbl_name,$tbl_key);		//创建表对象
//$t->printsql=1;

//构建查询条件

$query_conv='where 1';

//搜索条件开始
/** sample
模糊查询搜索
$inputname='表单名';
$paramname='字段名';
if($$inputname!='')
{
	$t->$paramname=$$inputname;
	$query_conv.=" and $paramname like '%".$$inputname."%'";
	$query_conv2[]=$paramname.',like';					
}
精确查询搜索
$inputname='表单名';
$paramname='字段名';
if($$inputname!='')
{
	$t->$paramname=$$inputname;
	$query_conv.=" and $paramname='".$$inputname."'";
	$query_conv2[]=$paramname.',=';					
}	//这里两个条件代表的意思是一样的，第二种为数据库类需要的格式
*/
//订单编号
$inputname='';
$paramname='';
$query_conv2[] = '';
if($inputname!='')
{
	$t->$paramname=$inputname;
	$query_conv.=" and $paramname='".$inputname."'";
	$query_conv2[]=$paramname.',=';					
}

//联系姓名
$inputname='';
$paramname='';
if($inputname!='')
{
	$t->$paramname=$$inputname;
	$query_conv.=" and $paramname like '%".$inputname."%'";
	$query_conv2[]=$paramname.',like';					
}

//联系电话
$inputname='';
$paramname='';
if($inputname!='')
{
	$t->$paramname=$$inputname;
	$query_conv.=" and $paramname like '%".$inputname."%'";
	$query_conv2[]=$paramname.',like';					
}

//联系姓名
$inputname='';
$paramname='';
if($inputname!='')
{
	//$t->$paramname=$$inputname;
	$query_conv.=" and $paramname in (select mem_id from member_merchant where mem_name='".$inputname."')";
	$otherconv=" and $paramname in (select mem_id from member_merchant where mem_name='".$inputname."')";				
}

//订单状态
$inputname='';
$paramname='';
if($inputname!='')
{
	$t->$paramname=$$inputname;
	$query_conv.=" and $paramname ='".$inputname."'";
	$query_conv2[]=$paramname.',like';					
}

//是否搜次日订单
$time1=strtotime(date("Y-m-d"))+86400;
$inputname='';
$paramname='';
if (isset($hurry)) {
  $hurry = $hurry;
} else {
  $hurry = 0;
}
if($hurry==1)
{
	$t->$paramname=$inputname;
	$query_conv.=" and $paramname = '".$inputname."'";
	$query_conv2[]=$paramname.',=';					
}
//是否搜今日订单
$time1=strtotime(date("Y-m-d"));
$inputname='';
$paramname='';
if($hurry==2)
{
	$t->$paramname=$inputname;
	$query_conv.=" and $paramname = '".$inputname."'";
	$query_conv2[]=$paramname.',=';					
}
//搜索条件结束

//计算记录数量
$otherconv = '';
if(count($query_conv2)==0)
{
	$otherconv="where 1 ".$otherconv;
}


$rs_num=$t->RsCount($query_conv2,$otherconv);
$pages=ceil($rs_num/$pagesize);
$page = 0;
if($page>$pages)
{
	$page=$pages;
}
if($page<1)
{
	$page=1;
}
$sql_limit=" limit ".($page-1)*$pagesize.",$pagesize";
//$t->printsql=1;
$rows=$t->GetAll('*',$query_conv.' order by '.$tbl_key.' desc'.$sql_limit);		//排序方式在此设置
?>
<table border="0" cellpadding="0" cellspacing="1" bgcolor="#999999" class="margintop30_l">
<?php
  $stu = 0;
  if (isset($_GET['stu'])) {
  	$stu = intval($_GET['stu']);
  }
  if($stu==2){?>
	<tr>
    <td height="25" colspan="12" align="left" bgcolor="#FFFFFF" style="border:none; height:30px; padding-left:10px;" ><input type="button" value="开始处理" class="redirect" confirm="true" withid="true" href="index_pcl.php?a=a" style=" background:#0080C0; color:#FFF; border:none;" /></td>
  </tr>
  <?php }?>
  <?php if($stu==3){?>
	<tr>
    <td height="25" colspan="12" align="left" bgcolor="#FFFFFF" style="border:none; height:30px; padding-left:10px;" ><input type="button" value="处理完订单" class="redirect" confirm="true" withid="true" href="index_pclwc.php?a=a" style=" background:#0080C0; color:#FFF; border:none;" /> <input type="button" value="处理失败" class="redirect" confirm="true" withid="true" href="index_pclsb.php?a=a" style=" background:#0080C0; color:#FFF; border:none;" /></td>
  </tr>
  <?php }?>
    <?php if($stu==4){?>
	<tr>
    <td height="25" colspan="12" align="left" bgcolor="#FFFFFF" style="border:none; height:30px; padding-left:10px;" ><input type="button" value="处理完订单" class="redirect" confirm="true" withid="true" href="index_pclycl.php?a=a" style=" background:#0080C0; color:#FFF; border:none;" /> </td>
  </tr>
  <?php }?>
  <tr>
  	<td width="50" height="25" align="center" class="title01"><input type="checkbox" id="chkAll" value="" /></td>
  	<td width="80" height="25" align="center" class="title01">订单编号</td>
  	<td width="120" height="25" align="center" class="title01">商品名称</td>
  	<td width="80" height="25" align="center" class="title01">购买数量</td>
  	<td width="100" height="25" align="center" class="title01">游玩日期</td>
  	<td width="100" align="center" class="title01">订单总价</td>
    <td width="100" align="center" class="title01">分销商名称</td>
  	<td width="100" align="center" class="title01">预订人</td>
    <td width="100" align="center" class="title01">下单时间</td>
  	<td width="100" height="25" align="center" class="title01">联系电话</td>
  	<td width="100" height="25" align="center" class="title01">订单状态</td>

    <td width="100" height="25" align="center" class="title01"><a href="<?=$url_add?>?<?=QueryString()?>" style="color:#C23734">增加记录</a></td>
  </tr>
<?php
if(is_array($rows) && count($rows)>0)
{
	foreach($rows as $key => $row)
	{
		$td_id=$row[$tbl_key];
		$td_op=getOrderActByStu($row);		#获取操作
		$td0='<a href="'.$url_mod.'?id='.$td_id.'&'.QueryString().'" style="color:#0080C0;">'.$row["Tord_ticketName"].'</a>';
		$td1=$row["Tord_num"];
		$td2=$row["Tord_playdate"]>0?date("Y-m-d",$row["Tord_playdate"]):'-';		#游玩日期
		$td3=$row["per_name"];		#预订人姓名
		$td4=$row["per_phone"];		#预订人联系电话
		$price=$row['Tord_price3']*$row['Tord_num'];	#总价=结算价*销售价
		$td5=getOrderStuByStuId($row["Tord_status"]);	#状态
		$tdname=getCstComById($row['Tord_cst_id']);
		$tdtime=date('Y-m-d H:i:s',$row['Tord_createtime']);

?>
  <tr>
  	<td height="25" align="center" bgcolor="#FFFFFF" class="list_td"><input type="checkbox" value="<?=$td_id?>" /></td>
    <td height="25" align="center" bgcolor="#FFFFFF" class="list_td"><?=$td_id?></td>
    <td height="25" bgcolor="#FFFFFF" class="list_td"><?=$td0?></td>
    <td height="25" align="center" bgcolor="#FFFFFF" class="list_td"><?=$td1?></td>
    <td height="25" bgcolor="#FFFFFF" class="list_td"><?=$td2?></td>
    <td align="right" bgcolor="#FFFFFF" class="list_td">&yen;<?=$price?></td>
     <td align="center" bgcolor="#FFFFFF" class="list_td"><?=$tdname?></td>
    <td align="center" bgcolor="#FFFFFF" class="list_td"><?=$td3?></td>
    <td width="100" align="center" bgcolor="#FFFFFF" class="list_td"><?=$tdtime?></td>
    <td height="25" align="center" bgcolor="#FFFFFF" class="list_td"><?=$td4?></td>
    <td height="25" align="center" bgcolor="#FFFFFF" class="list_td"><?=$td5?></td>

    <td height="25" align="center" bgcolor="#FFFFFF" class="list_td"><?=$td_op?></td>
  </tr>
<?php
	}
?>  
  <tr>
    <td height="25" colspan="12" align="right" bgcolor="#FFFFFF">
	<?php
	$helfstyle='?page=@';
	if(is_array($_GET))
	{
		foreach($_GET as $key => $value)
		{
			if($key=='page')
			{
				continue;
			}
			$helfstyle.='&'.$key.'='.$value;
		}
	}
	echo getPageNum($page,$pages,5,$helfstyle);
	?>
	&nbsp;</td>
  </tr>
  
<?php
}
else
{
?>
	<tr>
    	<td height="25" colspan="12" align="center" bgcolor="#FFFFFF">暂无内容&nbsp;...</td>
	</tr>
<?php
}
?>
</table>
<!-- 7caihu.com Baidu tongji analytics -->
<script type="text/javascript">
var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");

document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3Fb8797ecb21d1ccb839c35b190277a0cd' type='text/javascript'%3E%3C/script%3E"));

</script>
</body>
</html>
<?php
include_once($base_dir."inc/inc_unconnect.php")
?>